<template>
	<view class="tabBar-container">
		<view class="tab-list" @click="toSwitchTab(index)" v-for="(item,index) in showData.list" :key="index">
			<image v-if="showData.type == index" :src="item.selectedIconPath" mode="aspectFit"></image>
			<image v-else :src="item.iconPath" mode="aspectFit"></image>
			<view class="title" :style="{color: showData.type == index?'#000000':'#AFAFAF'}">{{item.title}}</view>
		</view>
	</view>
</template>

<script>
	var app = getApp();
	export default {
		name:"tabBar",
		props: {
			showData: {
				type: Object,
			},
			cssData:{
				type: String,
			}
		},
		data() {
			return {
				
			};
		},
		watch: {
			showData: {
				handler(newName, oldName) {
				},
				immediate: true,
				deep: true
			},
			cssData: {
				handler(newName, oldName) {
					
				},
				immediate: true,
				deep: true
			}
		},
		methods: {
			// 跳转
			toSwitchTab(index) {
				console.log(index,'index') ;
				console.log(this.showData.type,'indexxxx');
				if(this.showData.type == index) {
					// console.log(this.showData.type,'indexxxx');
					return
				}
				if(this.showData.list[index].status == 1) {
					uni.reLaunch({
						url: this.showData.list[index].url
					})
				} else {
					uni.switchTab({
						url: this.showData.list[index].url
					})
				}
			},
		}
	}
</script>

<style lang="scss">
	.tabBar-container {
		display: flex;
		padding: 12rpx 30rpx 6rpx 30rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		z-index: 999999;
		background: #fff;
		height: 92rpx;
		box-sizing: content-box;
		padding-bottom: constant(safe-area-inset-bottom);/* 兼容 iOS < 11.2 */
		padding-bottom: env(safe-area-inset-bottom); /* 兼容 iOS >= 11.2 */
		
		.tab-list {
			width: 100%;
			text-align: center;
			
			image {
				width: 40rpx;
				height: 40rpx;
				display: block;
				margin: 0 auto;
			}
			
			.title {
				margin-top: 8rpx;
				font-size: 20rpx;
				color: #7a7e83;
			}
		}
	}
</style>
